<?php

class Home extends Controller {

    public function  __construct() {
        parent::Controller();
        $this->load->model('contactmodel','contact');
		$this->load->model('photomodel', 'photo');
    }

    public function index() {
        $this->load->model('firmmodel', 'firm');
        $this->load->model('lawyermodel', 'lawyer');
        $this->load->model('headermodel', 'header');
        $data['firm'] = $this->firm->find();
        $data['lawyers'] = $this->lawyer->l_list();
        $data['advisers'] = $this->db->get('adviser')->result();
        $data['news'] = $this->db->get('news')->result();
		$data['header'] = $this->header->getHeader();
        $data['contact'] = $this->contact->find();
        $this->load->view('index', $data);
    }

    public function firm() {
        $this->load->model('firmmodel', 'firm');
        $data['advisers'] = $this->db->get('adviser')->result();
        $data['firm'] = $this->firm->find();
        $data['contact'] = $this->contact->find();
        $this->load->view('firm', $data);
    }

    public function header() {
        $this->load->model('headermodel', 'header');
        $data['advisers'] = $this->db->get('adviser')->result();
        $data['contact'] = $this->contact->find();
        $data['header'] = $this->header->getHeader();
        $this->load->view('header', $data);
    }

    public function lawyer() {
        $this->load->model('photomodel', 'photo');
        $this->load->model('lawyermodel', 'lawyer');
        $this->load->library('pagination');
        $data['contact'] = $this->contact->find();

        $limit = 5;
        $total = $this->lawyer->l_count();
        $offset = intval(isset($_GET['id'])?$_GET['id']:0);

        $config['base_url'] = base_url() . 'index.php/home/lawyer/';
        $config['total_rows'] = $total;
        $config['per_page'] = $limit;
        $this->pagination->initialize($config);

        $data['title'] = '久灵资讯';
        $data['lawyers'] = $this->lawyer->l_list($limit, $offset);
        $data['page_links'] = $this->pagination->create_links();

        $data['advisers'] = $this->db->get('adviser')->result();
        $this->load->view('lawyer', $data);
    }

    public function news() {
        $this->load->model('newsmodel','news');
        $this->load->library('pagination');

        $limit = 30;
        $total = $this->news->n_count();
        $offset = intval(isset($_GET['id'])?$_GET['id']:0);

        $config['base_url'] = base_url() . 'index.php/home/news/';
        $config['total_rows'] = $total;
        $config['per_page'] = $limit;
        $this->pagination->initialize($config);

        $data['title'] = '久灵资讯';
        $data['news'] = $this->news->n_list($limit, $offset);
        $data['page_links'] = $this->pagination->create_links();

        $data['advisers'] = $this->db->get('adviser')->result();
        $data['contact'] = $this->contact->find();
        $this->load->view('news', $data);
    }

    public function adviser(){
        $this->load->model('photomodel','photo');
        $this->load->model('newsmodel','news');

        $data['contact'] = $this->contact->find();
        $data['news'] = $this->news->n_list(8,0);
        $data['advisers'] = $this->db->get('adviser')->result();
        $this->load->view('adviser',$data);
    }

    public function contact(){
        $this->load->model('contactmodel','contact');
        $data['contact'] = $this->contact->find();
        $this->load->view('contact',$data);
    }

}

?>